import 'package:flutter/material.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:xinxuan/common/my_underline_tab_indicator.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/controllers/my_controller/blind_box_order_controller/blind_box_order_page_controller.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/views/my/blindBox_order/blind_box_order_arr.dart';

class BlindBoxOrderPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return GetBuilder<BlindBoxOrderPageController>(
      init: BlindBoxOrderPageController(),
      builder: (controller) {
        return Scaffold(
          backgroundColor: pageBgColor,
          appBar: AppBarUtil(
            title: '订单列表',
            backgroundColor: pageBgColor,
          ),
          body: DefaultTabController(
            length: controller.statusArr.length, 
            initialIndex: controller.tabIndex.value,
            child: Column(
              children: [
                ScrollConfigurationCommon(child: Container(
                  constraints: BoxConstraints(maxHeight: 44.h),
                  child: Material(
                    color: bgWhiteColor,
                    child: TabBar(  
                      indicator: MyUnderlineTabIndicator(
                        wantWidth: 20.w,
                        borderSide: BorderSide(
                          width: 5.h,
                          color: bgMainColor
                        )
                      ),
                      isScrollable: false,
                      indicatorColor: bgMainColor,
                      labelColor: mainTextColor,
                      unselectedLabelColor: textSubtitleColor,
                      labelStyle: TextStyle(
                        fontSize: 14.sp
                      ),
                      unselectedLabelStyle: TextStyle(
                        fontSize: 14.sp
                      ),
                      onTap: (index) {
                        controller.tabIndex.value = index;
                        controller.getBlindBoxOrderList();
                      },
                      labelPadding: EdgeInsets.symmetric(horizontal: 0),
                      // tabs: [
                      //   Container(
                      //     width: 75.w,
                      //     child: Tab(text: '全部'),
                      //   ),
                      //   Container(
                      //     width: 75.w,
                      //     child: Tab(text: '待提货'),
                      //   ),
                      //   Container(
                      //     width: 75.w,
                      //     child: Tab(text: '已转提'),
                      //   ),
                      //   Container(
                      //     width: 75.w,
                      //     child: Tab(text: '已自提'),
                      //   ),
                      //   Container(
                      //     width: 75.w,
                      //     child: Tab(text: '已核销'),
                      //   ),
                      // ]
                      tabs: controller.statusTypeStr.map((item) {
                        return Container(
                          width: 75.w,
                          child: Tab(text: item),
                        );
                      }).toList(),
                    ),
                  ),
                )),
                Expanded(child: Column(
                  children: [
                    SizedBox(height: 12.h),
                    Expanded(
                      child: Obx(() => BlindBoxOrderArr(seckillOrderListVo: controller.dataArr[controller.tabIndex.value], blindBoxOrderPageController: controller))
                    )
                  ],
                ))
              ],
            )
          ),
        );
      },
    );
  }
}